﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace DrawTools
{
    [Serializable]
    public class DrawAir : DrawRectangle
	{
        //public int driviceID { get; set; }   //设备ID
        //public int Ia { get; set; }          //电流A
        //public int Va { get; set; }          //电压A

        public int driviceID;// { get; set; }   //设备ID
        public int Ia; //{ get; set; }          //电流A
        public int Va;//{ get; set; }          //电压A

        public int DriviceID
        {
            get
            {
                return driviceID;
            }
            set
            {
                driviceID = value;
            }
        }

        public int IA
        {
            get
            {
                return Ia;
            }
            set
            {
                Ia = value;
            }
        }

        public int VA
        {
            get
            {
                return Va;
            }
            set
            {
                Va = value;
            }
        }

		public DrawAir() : this(0, 0, 1, 1)
		{
		}

        public DrawAir(int x, int y, int width, int height)
            : base()
        {
            Rectangle = new Rectangle(x, y, width, height);
            Initialize();
        }

        /// <summary>
        /// Clone this instance
        /// </summary>
        public override DrawObject Clone(DrawObject drawObject)
        {
            base.Clone(drawObject);
            return this;
        }

        // 重载属性保存方法
        public override void SaveToStream(System.Runtime.Serialization.SerializationInfo info, int orderNumber)
        {
            info.AddValue("driviceID" + orderNumber.ToString(),DriviceID);
            info.AddValue("Ia" + orderNumber.ToString(),IA);
            info.AddValue("Va" + orderNumber.ToString(),VA);

            base.SaveToStream(info, orderNumber);
        }

        // 
        public override void LoadFromStream(System.Runtime.Serialization.SerializationInfo info, int orderNumber)
        {
            DriviceID = info.GetInt32("driviceID" + orderNumber.ToString());
            IA = info.GetInt32("Ia" + orderNumber.ToString());
            VA = info.GetInt32("Va" + orderNumber.ToString());

            base.LoadFromStream(info, orderNumber);
        }

        public override void Draw(Graphics g)
        {           
            try
            {
                Pen pen = new Pen(Color, PenWidth);
                //g.DrawEllipse(pen, DrawRectangle.GetNormalizedRectangle(Rectangle));                
                //g.DrawImage(Image.FromFile(@"F:\资料\组态软件开发\组态思路\DrawTools\bin\Debug\" + "/Resources/Air.jpg")
                g.DrawImage(Image.FromFile(Common.FunctionClass.getRunPath() + "/Resources/Air.jpg")
                    , DrawRectangle.GetNormalizedRectangle(Rectangle));
                pen.Dispose();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            
        }


	}
}
